<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">订单管理</a>
            <a>
              <cite>订单列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">

                        <div class="layui-inline layui-show-xs-block">
                            <select class="layui-select" name="status">
                                <option value="-1">选择状态</option>
                                @foreach($status as $key => $state)
                                <option value="{{$key}}" @if($params['status'] == $key) selected @endif>{{$state}}</option>
                                @endforeach
                            </select>
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <select name="brand"  class="layui-select">
                                <option value="-1">选择品牌</option>
                                @foreach($brands as $brand)
                                <option value="{{$brand->id}}" @if($params['brand'] == $brand->id) selected @endif>{{$brand->name}}</option>
                                @endforeach
                            </select>
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <input value="{{$params['name']}}" name="name"  placeholder="输入用户" autocomplete="off" class="layui-input">
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <input value="{{$params['date']}}" name="date"  placeholder="预约日期" autocomplete="off" class="layui-input" id="date">
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <input type="checkbox" name="export" title="导出" class="layui-checkbox">
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                {{--<div class="layui-card-header">--}}
                    {{--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>--}}
                {{--</div>--}}
                <style>
                    td{
                        padding-right:0 !important;
                    }
                </style>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            {{--<th>--}}
                                {{--<input type="checkbox" lay-filter="checkall" name="" lay-skin="primary">--}}
                            {{--</th>--}}
                            <th>内部ID</th>
                            <th>中行ID</th>
                            <th>用户名/手机</th>
                            <th>门店</th>
                            <th>预约时间</th>
                            <th>产品</th>
                            <th>内部卡密</th>
                            <th>供货商卡密</th>
                            <th>状态</th>
                            <th>备注</th>
                            <th>下单时间</th>
                            <th>操作</th></tr>
                        </thead>
                        <tbody>
                        @foreach($orders as $order)
                        <tr>
                            {{--<td>--}}
                                {{--<input type="checkbox" name="id" value="1"   lay-skin="primary">--}}
                            {{--</td>--}}
                            <td>{{$order->order_id}}</td>
                            <td>{{$order->bank_order_id}}</td>
                            <td>{{$order->user_name}}<br/>{{$order->user_mobile}}</td>
                            <td>{{$order->shop->name}}</td>
                            <td>{{$order->book_date}}</td>
                            <td>
                                @foreach($order->goods as $g)
                                    {{$g->name}}
                                @endforeach
                            </td>
                            <td>{{$order->card?$order->card->account:''}} <br/> {{$order->card?$order->card->password:''}}</td>
                            <td>{{$order->shop_card}}@if($order->shop_card) <br/> @endif{{ $order->shop_pwd}}</td>
                            <td>{{$order->status}}</td>
                            <td>用户：{{$order->note}}<br/>客服：{{$order->admin_note}}</td>
                            <td>{{$order->created_at}}</td>
                            <td class="td-manage">
                                <a title="编辑" class="layui-btn" onclick="xadmin.open('订单编辑','orderEdit?id={{$order->order_id}}',700,500)" href="javascript:;">
                                    <i class="layui-icon">&#xe642;</i>
                                </a>

                                <a class="layui-btn layui-btn-danger" title="删除" onclick="member_del(this,{{$order->order_id}})" href="javascript:;">
                                    <i class="layui-icon">&#xe640;</i>
                                </a>
                            </td>
                        </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">

                       {{$orders->appends($params)->links()}}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;


        // 监听全选
        form.on('checkbox(checkall)', function(data){

            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#date' //指定元素
        });
    });

    /*用户-停用*/
    function member_stop(obj,id){
        layer.confirm('确认要停用吗？',function(index){

            if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

            }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
            }

        });
    }

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            layui.jquery.get({
                url:'./orderDel?id='+id,
                success:function(){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                },
                fail:function(){

                }
            })

        });
    }



    function delAll (argument) {
        var ids = [];

        // 获取选中的id
        $('tbody input').each(function(index, el) {
            if($(this).prop('checked')){
                ids.push($(this).val())
            }
        });

        layer.confirm('确认要删除吗？'+ids.toString(),function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
    }

</script>
</html>
